cmake_minimum_required(VERSION 2.8)
project(proj)
file(GLOB lib_srcs *.c)
set(lib_hdrs proj.h proj_api.h projects.h geodesic.h)
set(CMAKE_DEBUG_POSTFIX "D")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/proj_config.h.in proj_config.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(${PROJECT_NAME} SHARED ${lib_hdrs} ${lib_srcs} ${PROJECT_NAME}.def)
install(FILES ${lib_hdrs} DESTINATION include)
install(DIRECTORY nad/ DESTINATION share)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)

if(BUILD_STATIC)
  add_library(${PROJECT_NAME}S STATIC ${lib_hdrs} ${lib_srcs})
  install(TARGETS ${PROJECT_NAME}S EXPORT ${PROJECT_NAME}S-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
  install(EXPORT ${PROJECT_NAME}S-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}S-config.cmake)
endif()
